package com.atguigu.srb.core.controller.api;


import com.atguigu.srb.base.config.JwtUtils;
import com.atguigu.srb.commom.result.R;
import com.atguigu.srb.core.Vo.UserBindVO;
import com.atguigu.srb.core.service.UserBindService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 用户绑定表 前端控制器
 * </p>
 *
 * @author lay_hu
 * @since 2021-12-13
 */
@Api(tags = "会员账号绑定")
@RestController
@RequestMapping("/api/core/userBind")
@Slf4j
public class UserBindController {
    @Resource
    UserBindService userBindService;
     @ApiOperation("用户绑定")
     @PostMapping("/auth/bind")
    public R bind(@RequestBody UserBindVO bindVO, HttpServletRequest httpServletRequest){

        String token = httpServletRequest.getHeader("token");
        Long userId = JwtUtils.getUserId(token);
       String FormString= userBindService.commitBindUser(bindVO,userId);

       return  R.ok().data("FormString",FormString);


    }


}

